package org.enlongWu.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.enlongWu.pojo.Article;
import org.enlongWu.pojo.User;

import java.util.Collection;
import java.util.List;

@Mapper
public interface UserMapper {

    //根据用户名查询用户
    @Select("select * from user where username=#{username} ")
    User findByUserName(String username);

    //根据用户名查询用户
    @Select("select * from user where id=#{id} ")
    User findByUserId(Integer id);

    void add(String username, String password,String nickname,String email,String userPic,String role);

    //更新用户信息
    void update(User user);

    //更新用户头像
    @Update("update user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")
    void updateAvatar(String avatarUrl, Integer id);

    //更新用户密码
    @Update("update user set password=#{md5String},update_time=now() where id=#{id}")
    void updatePwd(String md5String, Integer id);

    List<User> list(String searchString,String role);

    List<User> getUserListByRole(String role);
}
